import 'package:casdon/common/state/common_net_status.dart';
import 'package:casdon/modules/login/domain/states/login_state.dart';

class LoginPwdState extends LoginState {
  final String? account;
  final String? pwd;
  static const Object _sentinel = Object();
  LoginPwdState({
    required super.status,
    super.message,
    required super.version,
    super.agreed,
    this.account,
    this.pwd,
    super.errorCode,
  });

  factory LoginPwdState.initial() => LoginPwdState(
    status: CommonNetStatus.idle,
    version: 1,
    agreed: false,
    account: null,
    pwd: null,
    errorCode: null,
  );

  @override
  LoginPwdState copyWith({
    Object? status = _sentinel,
    Object? message = _sentinel,
    Object? version = _sentinel,
    Object? account = _sentinel,
    Object? pwd = _sentinel,
    Object? agreed = _sentinel,

    Object? errorCode = _sentinel,
  }) {
    return LoginPwdState(
      status: status == _sentinel
          ? this.status
          : status as CommonNetStatus? ?? this.status,
      message: message == _sentinel ? this.message : message as String?,
      version: version == _sentinel
          ? this.version
          : version as int? ?? this.version,
      agreed: agreed == _sentinel
          ? this.agreed
          : agreed as bool? ?? this.agreed,
      errorCode: errorCode == _sentinel ? this.errorCode : errorCode as String?,
      account: account == _sentinel ? this.account : account as String?,
      pwd: pwd == _sentinel ? this.pwd : pwd as String?,
    );
  }

  // 可选：覆盖父类方法以返回子类类型
  @override
  LoginPwdState toIdle() => copyWith(
    status: CommonNetStatus.idle,
    version: version + 1,
    agreed: false,
    message: null,
    account: null,
    pwd: null,
    errorCode: null,
  );

  @override
  LoginPwdState toLoading() => copyWith(
    status: CommonNetStatus.loading,
    version: version + 1,
    errorCode: null,
    message: null,
  );

  // ...其他方法同理
}
